import { request } from '../../utils/request'
Page({

    /**
     * 页面的初始数据
     */
    data: {
      songList:[],
      showShare: false,
        options: [
          { name: '微信', icon: 'wechat', openType: 'share' },
          { name: '微博', icon: 'weibo' },
          { name: '复制链接', icon: 'link' },
          { name: '分享海报', icon: 'poster' },
          { name: '二维码', icon: 'qrcode' },
      ],
    },
    
    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function (options) {

    },

    /**
     * 生命周期函数--监听页面显示
     */
    async onShow() {
      let songListData = await request('/song')
      this.setData({
        songList:songListData.data
      })
    },
    tosongs(e){
      let index = e.currentTarget.dataset.index
        let currentMusic =  this.data.songList[index]
        wx.navigateTo({
          url: '/pages/songs/songs',
          success: function(res) {
            res.eventChannel.emit('detail', { musicData:currentMusic})
          }
        })
    },
    share(){
      this.setData({ showShare: true });
    
    },
    onClose() {
      this.setData({ showShare: false });
    },
    onSelect(event) {
      Toast(event.detail.name);
      this.onClose();
    },

})